package com.ansion.baseui.base;

import android.view.View;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;

import com.ansion.baseui.base.actionbar.TActionBar;
import com.ansion.baseui.base.loading.CustomAlertDialog;
import com.ansion.baseui.base.toolbar.TActionBarSupport;


/**
 * created by zhaoyuntao
 * on 22/02/2022
 * description:
 */
public abstract class TVPActivityUIProxy<A extends TVPBaseActivity<?>, P extends TBasePresenter<?>> extends TVPBaseUIProxy<A, P> implements ToastSupport, TActionBarSupport, LoadingSupport {

    public TVPActivityUIProxy(A a) {
        super(a);
    }

    @Override
    final public A activity() {
        return getView();
    }

    @Override
    public TActionBar getTActionBar() {
        return activity().getTActionBar();
    }

    @Override
    public void setTActionBarVisible(boolean visible) {
        activity().setTActionBarVisible(visible);
    }

    @SuppressWarnings("TypeParameterUnusedInFormals")
    final public <T extends View> T findViewById(@IdRes int id) {
        return getView().findViewById(id);
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    final public <UIProxy extends TVPActivityUIProxy> UIProxy getUIProxy(Class<UIProxy> clazz) {
        return (UIProxy) activity().getUIProxy(clazz);
    }

    @Override
    final public CustomAlertDialog getLoadingDialog() {
        return activity().getLoadingDialog();
    }

    @Override
    final public void onSetLoadingDialog(@Nullable CustomAlertDialog loadingDialog) {
        activity().onSetLoadingDialog(loadingDialog);
    }

    protected void registerOnClickListener(@IdRes int resId) {
        getView().registerOnClickListener(resId);
    }

    protected void onStartActivity() {

    }

    protected void onRestartActivity() {

    }

    protected void onResumeActivity() {

    }

    protected void onPauseActivity() {

    }

    protected void onStopActivity() {

    }

    protected void onDestroyActivity() {

    }

    protected void onFinishActivity() {

    }
}
